/*
 * parentCenter.js
 */
$(document).ready(function(){
	/*
	 * for auto slide of images
	 */
	var speed = 3000;
	var gallery = document.getElementById("outerImgGallery");
	
	function autoRun(){
		nextImg("outerImgGallery", "insideImgGallery");
	}

	var autoRunMethod = setInterval(autoRun, speed);
	gallery.onmouseover = function() {clearInterval(autoRunMethod)};
	gallery.onmouseout = function() {autoRunMethod = setInterval(autoRun, speed)};
	
	/*
	 *  roll news
	 */
	var rnSpeed = 30;
	var rnOuter = document.getElementById("RNOuter");
	var rnInside = document.getElementById("RNInside");
	var width = rnInside.style.width;

	function rnSlide(){
		if(rnOuter.scrollLeft > 1450){
			rnOuter.scrollLeft = 0;
		}else{
			rnOuter.scrollLeft = rnOuter.scrollLeft + 1;
		}
	}

	var rnSlideMethod = setInterval(rnSlide, rnSpeed);
	rnOuter.onmouseover=function() {clearInterval(rnSlideMethod)};
	rnOuter.onmouseout=function() {rnSlideMethod=setInterval(rnSlide, rnSpeed)};

})

/*
 * images slide
 */
function previousImg(gallery, galleryInside){
	
	var mediaGallery = document.getElementById(gallery);
	var width = document.getElementById(galleryInside).style.width;
	
	if(mediaGallery.scrollLeft == 0){
		mediaGallery.scrollLeft = parseInt(width) - 430;
	}else{
		mediaGallery.scrollLeft = mediaGallery.scrollLeft - 430;
	}
	
}

function nextImg(gallery, galleryInside){
	
	var mediaGallery = document.getElementById(gallery);
	var width = document.getElementById(galleryInside).style.width;
	
	if(mediaGallery.scrollLeft == (parseInt(width) - 430)){
		mediaGallery.scrollLeft = 0;
	}else{
		mediaGallery.scrollLeft = mediaGallery.scrollLeft + 430;
	}
}

///*
// *  roll news
// */
//var rnSpeed = 10;
//var rnOuter = document.getElementById("RNOuter");
//var rnInside1 = document.getElementById("RNInside1");
//var rnInside2 = document.getElementById("RNInside2");
//rnInside2.innerHTML = rnInside1.innerHTML;
//
//function rnSlide(){
//	if(rnInside2.offsetWidth-rnInside1.scrollLeft<=0)
//		rnOuter.scrollLeft-=rnInside1.offsetWidth
//	else{
//		rnOuter.scrollLeft++;
//	}
//}
//
//var rnSlideMethod = setInterval(rnSlide, speed);
//rnOuter.onmouseover=function() {clearInterval(rnSlideMethod)};
//rnOuter.onmouseout=function() {rnSlideMethod=setInterval(rnSlide, speed)};



